package fakeSmarthouseHW;

import java.util.LinkedList;

import smarthouse.Smarthouse;

public class FakeSmarthouse {
	
	private static FakeSmarthouse instance = new FakeSmarthouse();
	
	LinkedList<FakeDevice> hardwareDevices = new LinkedList<FakeDevice>();
	
	
	private FakeSmarthouse(){
		hardwareDevices.add(new FakeHeater(1));
		hardwareDevices.add(new FakeHeater(2));
		hardwareDevices.add(new FakeLight(3));
		hardwareDevices.add(new FakeHeater(4));
		hardwareDevices.add(new FakeLight(5));
		hardwareDevices.add(new FakeLight(6));
		hardwareDevices.add(new FakeLight(7));
	}
	
	
	public static FakeSmarthouse getInstance(){
		return instance;
	}
	
	public void broadcastCommand(int deviceId, int commandId, LinkedList<Object> params){
		//FakeDevice device = hardwareDevices.get(deviceId-1);
		//device.execCommand(deviceId, commandId, params);
		
		for (FakeDevice device : hardwareDevices) {
			device.execCommand(deviceId, commandId, params);
		}
        
		
	}
	
	public LinkedList<Object> fetchDeviceState(int deviceId){
		for (FakeDevice device : hardwareDevices) {
			if (device.id == deviceId)
				return device.getData();
		}
		//FakeDevice device = hardwareDevices.get(deviceId-1);
		//return device.getData();
		return null;
	}
	
	

}
